<template>
  <div>
    <el-page-header content="详情页面" @back="goBack"/>
    <p>
      {{ companyHistory }}{{ companyHistory }}
    </p>


    <el-table
        :data="commentsList"
        :highlight-current-row="true"
        border
        current-row-key="airlineId"
        stripe
        style="width: 100%"
    >
      <el-table-column align="center"
                       label=""
                       type="index"
                       width="50">
      </el-table-column>
      <el-table-column align="left"
                       prop="commentsContent"
      >
      </el-table-column>
      <el-table-column align="left"
                       label="评论时间"
                       prop="commentsTime"
      >
      </el-table-column>

    </el-table>
    <div>
      <el-input v-model="formLabelAlign.commentsContent"></el-input>
      <el-button type="primary" @click="handleAdd()">发送</el-button>
    </div>

  </div>
</template>

<script>
export default {
  name: "u_companyInfo",
  data() {
    return {
      companyId: '',
      companyHistory: '',
      commentsList: [],
      formLabelAlign: {
        commentsContent: '',
        companyId: '',
      }
    }
  },
  created() {
    this.companyId = this.$route.query.companyId;
    this.companyHistory = this.$route.query.companyHistory;
    this.getInfo();
    this.formLabelAlign.companyId = this.$route.query.companyId;
  },
  methods: {
    getInfo() {
      let paramStr = "?companyId=" + this.companyId;
      this.axios
          .get("/comments/page/1/10/" + paramStr)
          .then(res => {
            this.commentsList = res.data.data.records;
          })

    },
    goBack() {
      window.history.back();
    },
    handleAdd() {
      let Param = window.sessionStorage.getItem("token");
      this.axios
          .post("/comments/add/", {
            companyId: this.formLabelAlign.companyId,
            commentsContent: this.formLabelAlign.commentsContent,
            token: Param

          })
          .then(res => {
            if (res.data.code === 200) {
              this.$message.success(res.data.msg);
              this.getInfo();
            } else {
              this.$message.error(res.data.msg);
            }

          })
    }
  }
}
</script>

<style scoped>

</style>